function out = regressYGapOnSlope(data,shortRate,maturities,ygap,h)

T             = size(data,1);
n             = length(maturities);
beta          = nan(2,n);
R2            = nan(1,n);
beta_tstat    = nan(2,n);
startMat      = find(maturities >= 2*12);
for i=startMat:n
   Y              = ygap(1+h:T,1);
   x              = data(1:T-h,i)-shortRate(1:T-h,1);
   X              = [ones(T-h,1) x];
   results        = nwest(Y,X,3);
   beta(:,i)      = results.beta;           
   R2(1,i)        = results.rsqr;
   beta_tstat(:,i)= results.tstat;
end


% Saving the results
out.beta             = beta;
out.R2               = R2;
out.beta_tstat       = beta_tstat;
out.maturities       = maturities;

end